package com.wkbb.sports.model;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.wkbb.sports.dto.TrainDto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

//房间数据
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class StudentOnlineRoomData implements Serializable {
    @ApiModelProperty(value = "倒计时：秒")
    private Integer countdown;
    @ApiModelProperty(value = "学生列表")
    private List<RoomDataStudent> stuList = new ArrayList<>();

    public void setStuList(List<StudentOnlineRoomStu> stuList) {
        this.stuList.clear();
        stuList.forEach(item -> {
            if (item.getState() == 2){
                RoomDataStudent roomDataStudent = new RoomDataStudent();
                roomDataStudent.setStudentId(item.getStudentId());
                roomDataStudent.setStudentName(item.getStudentName());
                roomDataStudent.setHeadImgUrl(item.getHeadImgUrl());
                roomDataStudent.setCount(item.getCount());
                this.stuList.add(roomDataStudent);
            }
        });
    }

    @Data
    class RoomDataStudent implements Serializable{
        @ApiModelProperty(value = "学生编号")
        private Long studentId;
        @ApiModelProperty(value = "学生姓名")
        private String studentName;
        @ApiModelProperty(value = "头像")
        private String headImgUrl;
        @ApiModelProperty(value = "当前跳绳成绩")
        private Integer count = 0;
    }
}